<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			/*
			   类
			   class 子类 extends 父类 {
				   
			   }
			*/

			//父类
			class Person {
				//构造方法
				constructor(name, age) {
					this.name = name;
					this.age = age;
				}
				//一般方法
				eat() {
					console.log("吃饭");
				}
			}
			
			// Person.prototype

			//子类
			class Student extends Person {
				constructor(name, age, score) {
					super(name, age); //调用父类构造方法
					this.score = score;
				}
				study() {
					console.log("学习");
				}
			}

			//子类
			class Worker extends Person {
				constructor(name, age, salary) {
					super(name, age);
					this.salary = salary;
				}
			}
            //调用构造方法（构建对象的方法）
			var s1 = new Student("张三", 20, 99);
			
			var s2 = new Student("李四", 30, 89);

			console.log(s1.name);
			// s1.study();
			// s1.eat();
			
			console.dir(Student);
		</script>
	</head>
	<body>
	</body>
</html>
